/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package config.Models;

import config.ConfigMacros;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.json.simple.JSONArray;
import libCore.Util;

/**
 *
 * @author LinhTA
 */
public class Conf_Mix {
    
    public RequireMix requireMix;
    public ToMix toMix;
    
    public Conf_Mix(Map<String, Object> obj)
    {
        requireMix = new RequireMix(Util.obj2Map(obj.get(ConfigMacros.MIX_REQUIRE)));
        toMix = new ToMix(Util.obj2Map(obj.get(ConfigMacros.MIX_TO)));
    }
    
    public  class RequireMix
    {
        public int level;
        public int gold;
        public int coin;
        public List<RequireMixEtt> entities = new ArrayList<RequireMixEtt>();
        
        public RequireMix(Map<String, Object> obj)
        {
            level = Integer.parseInt(obj.get(ConfigMacros.LEVEL).toString());
            gold = Integer.parseInt(obj.get(ConfigMacros.GOLD).toString());
            coin = Integer.parseInt(obj.get(ConfigMacros.COIN).toString());
            
            JSONArray et = (JSONArray) obj.get(ConfigMacros.MIX_REQUIRE_ENTITIES);
            
            for (int i = 0; i < et.size(); i++) {
               RequireMixEtt reqett = new RequireMixEtt( Util.obj2Map(et.get(i)));
                entities.add(reqett);
            }
        }
    }
    
    public  class ToMix
    {
        public String kind;
        public String entity;
        
        public ToMix(Map<String, Object> obj)
        {
            kind = obj.get(ConfigMacros.MIXITEM_KIND).toString();
            entity = obj.get(ConfigMacros.MIXITEM_ENTITY).toString();
        }
    }
    
     public class RequireMixEtt
    {
         public String mixItem;
         public int sum;
         
        public RequireMixEtt(Map<String,Object> obj)
        {
            mixItem = obj.get(ConfigMacros.MIX_REQUIRE_ENTITIES_ITEM).toString();
           sum = Integer.parseInt(obj.get(ConfigMacros.MIX_REQUIRE_ENTITIES_SUM).toString());
        }
     }
}
